<?php
class RoleAction extends CommonAction {

	public $dao;
	public function _initialize(){
		parent::_initialize();
		$this->dao = D('User');
	}
	
    public function index(){
		$user=$this->dao;
		import ( '@.ORG.Page' );
		$count=$user->count();
		$page=new Page($count,20);
		$page->setConfig('theme','<div class="pageinfo">%totalRow% %header% %nowPage%/%totalPage% 页</div> %first% %upPage% %prePage%  %linkPage%  %nextPage%  %downPage% %end%');
		$show=$page->show();
		$this->assign("page",$show);
		
		$userlist=$user->order('id')->limit($page->firstRow.','.$page->listRows)->select();
		$this->assign('userlist',$userlist);
		$this->display();
    }
	
	public function add(){
		$this->display('edit');
    }
	
	public function insert(){
		$user=$this->dao;
		if($data=$user->create()){
			if(false!==$user->add()){
				//$uid=$user->getLastInsID();
//				$ru['role_id']=$_POST['groupid'];
//				$ru['user_id']=$uid;
//				$roleuser=M('RoleUser');
//				$roleuser->add($ru);			
				$this->success(L('add_ok'));
			}else{
				$this->error(L('add_error'));
			}
		}else{
			$this->error($user->getError());
		}
	}
	
	
}
?>